package com.cskaoyan.controller;

import com.cskaoyan.service.GroupBuyingsVoService;
import com.cskaoyan.vo.BaseRespVo;
import com.cskaoyan.vo.GroupBuyingsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.MonthDay;

@RestController

public class GroupBuyingcontroller {
    @Autowired
    GroupBuyingsVoService groupBuyingsVoService;

    @RequestMapping("admin/groupon/list")// http://localhost:8083/admin/groupon/list?page=1&limit=20&sort=add_time&order=desc
    public BaseRespVo groupbuying(Integer page, Integer limit, String sort, String order, Integer goodsId){
        if(goodsId == null ) {
            GroupBuyingsVo groupBuyingsVo = groupBuyingsVoService.query(page, limit, sort, order);
            return BaseRespVo.ok(groupBuyingsVo);
        }
        if(goodsId != null){
            System.out.println("他到这里来了");
            BaseRespVo baseRespVo = new BaseRespVo();
            GroupBuyingsVo groupBuyingsVo = groupBuyingsVoService.found(page, limit, sort, order,goodsId);
            return baseRespVo.ok(groupBuyingsVo);
        }
        return new BaseRespVo();
    }
    @RequestMapping("admin/groupon/listRecord")
    public BaseRespVo listRecord(Integer page, Integer limit, String sort, String order) {

        BaseRespVo baseRespVo = new BaseRespVo();

        return baseRespVo.ok();
    }

    @RequestMapping("admin/groupon/create")
    public BaseRespVo create(){

        return new BaseRespVo();
    }
    @RequestMapping("admin/role/options")
    public BaseRespVo role(){
        return new BaseRespVo();
    }
}
